# Contributor: guddaff <guddaff@protonmail.com>
# Maintainer: guddaff <guddaff@protonmail.com>
pkgname=mqttui
pkgver=0.16.2
pkgrel=2
pkgdesc="Subscribe to a MQTT Topic or publish something quickly from the terminal"
url="https://github.com/EdJoPaTo/mqttui"
# ppc64le: blocked by ring
# riscv64, s390x: blocked by cargo/rust
arch="all !ppc64le !riscv64 !s390x"
license="GPL-3.0-or-later"
makedepends="cargo"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/EdJoPaTo/mqttui/archive/v$pkgver/$pkgname-$pkgver.tar.gz"

export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"
export CARGO_PROFILE_RELEASE_PANIC="abort"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	cargo install --locked --path . --root="$pkgdir/usr"
	rm "$pkgdir"/usr/.crates*

	install -Dm644 "target/completions/$pkgname.bash" "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 "target/completions/$pkgname.fish" -t "$pkgdir"/usr/share/fish/completions/
	install -Dm644 "target/completions/_$pkgname" -t "$pkgdir"/usr/share/zsh/site-functions/
}

sha512sums="
9fddfd538cc8a802bab6073d79e230c34cb9f8c22a14597d80f2dd272d627297b14959f0a459ceb70ac7cfe4622cec47db7aed0ef6329b377b51a9d72da93a39  mqttui-0.16.2.tar.gz
"
